package com.dyyx.nettyrpc.test.app;

import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.dyyx.nettyrpc.client.RpcClient;
import com.dyyx.nettyrpc.test.client.HelloService;
import com.dyyx.nettyrpc.test.client.Person;
import com.dyyx.nettyrpc.test.client.PersonService;

public class ClientMain {

	public static void main(String[] args) {
		ApplicationContext ctx = new ClassPathXmlApplicationContext("client-spring.xml");
		System.out.println("ctx=" + ctx);

		RpcClient rpcClient = (RpcClient) ctx.getBean("rpcClient");

		HelloService helloService = rpcClient.create(HelloService.class);
		String result = helloService.hello("World");

		System.out.println(result);

		Person person = new Person("du", "gang");
		result = helloService.hello(person);
		System.out.println(result);

		PersonService personService = rpcClient.create(PersonService.class);
		int num = 3;
		List<Person> persons = personService.GetTestPerson("cat", num);

		for (Person item : persons) {
			System.out.println(item);
		}

	}
}
